<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@page import="com.su.middleware.login.LoginVerifier"%>

<%
String userID = request.getParameter("userID");
if (userID == null || userID.length() == 0) {
	out.println("Username is required!");
	return;
}
String userPassword = request.getParameter("userPassword");
if (userPassword == null || userPassword.length() == 0) {
	out.println("User password is required!");
	return;
}

String desiredGroupID = request.getParameter("desiredGroupID");
if (desiredGroupID == null || desiredGroupID.length() == 0) {
	out.println("User's group ID is required!");
	return;
}

boolean userValid = LoginVerifier.checkLogin(userID, desiredGroupID);
if (!userValid)
{
	out.println("User is invalid, check your credentials! groupID: " + desiredGroupID);
	return;
}

// Valid login
session.setAttribute("authorized", "yes");
session.setAttribute("userid", userID);
session.setAttribute("groupid", desiredGroupID);
%>
<jsp:forward page='<%=request.getParameter("authorizedPage")%>' />
